﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ShopOnline.BLL;

namespace ShopOnline.Admin
{
    public partial class SlideShow : AdminBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ((AdminMaster)this.Master).SetPageTitle("Slide Show Module");
            if (!IsPostBack)
            {
                LoadData();
            }
        }

        protected void gvSlideShow_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Remove")
            {
                //remove
                int id = Convert.ToInt32(e.CommandArgument);
                ShopOnline.BLL.SlideShow slide = ShopOnline.BLL.SlideShow.GetByID(id);
                slide.MarkAsDeleted();
                slide.Save();
                LoadData();
            }
        }

        private void LoadData()
        {
            ShopOnline.BLL.SlideShow slides = ShopOnline.BLL.SlideShow.GetAll();
            gvSlideShow.DataSource = slides.DefaultView;
            gvSlideShow.DataBind();
        }
    }
}